import uvicorn

from apps import app

if __name__ == '__main__':
    uvicorn.run(app, host="127.0.0.1", port=8000)
    
async def init_membership_levels():
    """初始化会员等级数据"""
    from models.user import MembershipLevel
    levels = [
        {"name": "普通", "upgrade_amount": 0.00, "level": 0},
        {"name": "白银", "upgrade_amount": 99.00, "level": 1},
        {"name": "黄金", "upgrade_amount": 199.00, "level": 2},
        {"name": "钻石", "upgrade_amount": 299.00, "level": 3}
    ]
    for level in levels:
        await MembershipLevel.get_or_create(
            name=level["name"],
            defaults={
                "upgrade_amount": level["upgrade_amount"],
                "level": level["level"]
            }
        )